﻿using System;
using Mrkz.ImageManipulation;
using Mrkz.ImageManipulation.FrequencyFiltering;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Mrkz.ImageManipulation.Test
{
    [TestClass]
    public class DFTengineTest
    {
        [TestMethod]
        public void DFTSquarePow2TestEquality()
        {
            TImage<Pixel> im = ImageFactory<Pixel>.FromBitmapSource(utils.LoadImage("square_pow2.jpg"));

            DFTEngine engine = new DFTEngine();
            TImage<ComplexPixel> c = engine.ForwardTransform(im);

            TImage<Pixel> imout = engine.InverseTransform(c);

            Assert.IsTrue(imout.Equals(im, 1));
            Assert.IsTrue(im.Equals(imout, 1));
        }

        [TestMethod]
        public void DFTSquareTestEquality()
        {
            TImage<Pixel> im = ImageFactory<Pixel>.FromBitmapSource(utils.LoadImage("square.png"));

            DFTEngine engine = new DFTEngine();
            TImage<ComplexPixel> c = engine.ForwardTransform(im);

            TImage<Pixel> imout = engine.InverseTransform(c);

            Assert.IsTrue(imout.Equals(im, 1));
            Assert.IsTrue(im.Equals(imout, 1));
        }

        [TestMethod]
        public void DFTRectPow2TestEquality()
        {
            TImage<Pixel> im = ImageFactory<Pixel>.FromBitmapSource(utils.LoadImage("rect_pow2.bmp"));

            DFTEngine engine = new DFTEngine();
            TImage<ComplexPixel> c = engine.ForwardTransform(im);

            TImage<Pixel> imout = engine.InverseTransform(c);

            Assert.IsTrue(imout.Equals(im, 1));
            Assert.IsTrue(im.Equals(imout, 1));
        }

        [TestMethod]
        public void DFTRectTestEquality()
        {
            TImage<Pixel> im = ImageFactory<Pixel>.FromBitmapSource(utils.LoadImage("rect.bmp"));

            DFTEngine engine = new DFTEngine();
            TImage<ComplexPixel> c = engine.ForwardTransform(im);

            TImage<Pixel> imout = engine.InverseTransform(c);

            Assert.IsTrue(imout.Equals(im, 1));
            Assert.IsTrue(im.Equals(imout, 1));
        }
    }
}
